package cn.slt.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.slt.domian.MD_libraryDSID;
import cn.slt.domian.users;
import cn.slt.service.MD_classDSIDService;
import cn.slt.service.MD_libraryDSIDService;
import cn.slt.service.usersService;

@Controller

public class MD_libraryDSIDController {
	@Autowired
	private MD_libraryDSIDService libservice;
	@Autowired
	private usersService userservice;
	@RequestMapping("updatelib_lzd")
	@ResponseBody
	public String updatelib(@RequestParam String dsname,@RequestParam String liburl,@RequestParam String buildUnit,@RequestParam String staff,@RequestParam String databasestand,
			@RequestParam String mangUnit,@RequestParam String mangStaff,@RequestParam Date startTime,
			@RequestParam String keywords,@RequestParam String beizhu,
			@RequestParam String attention,@RequestParam String useConstr,@RequestParam String secLev,
			@RequestParam String othConstr,@RequestParam String exchangeEnv,@RequestParam String service)//参数可以多，但是必须要有规定的这些
	{   
		boolean mark=false;
		String words=null;
		MD_libraryDSID obj=new MD_libraryDSID();
		obj.setDsName(dsname.trim().toUpperCase());
		obj.setBuildUnit(buildUnit);
		obj.setStaff(staff);
		obj.setStandname(databasestand);
		obj.setMangUnit(mangUnit);
		obj.setMangStaff(mangStaff);
		obj.setStartTime(startTime);
		obj.setKeywords(keywords);
		obj.setLocation(liburl);
		obj.setBeizhu(beizhu);
		obj.setAttention(attention);
		obj.setUseconstr(useConstr);
		obj.setSeclevl(secLev);
		obj.setOtherconstr(othConstr);
		obj.setExchangeEnv(exchangeEnv);
		obj.setService(service);
//		users user=new users();
//		user.setLocation(liburl);
//		user.setOwner(dsname.trim().toUpperCase());
//		user.setState("1");
//		user.setUsername(buildUnit);
//		try {
//			userservice.updateusers(user);
//		} catch (Exception e) {
//			// TODO: handle exception
//		}
		try{
			mark=libservice.updatelib(obj);
			System.out.println("yichang1");
			if (mark){
				words = "1";
			} else {
				words ="2";
			}
		}catch(Exception e){
			words="0";
			System.out.println("yichang");
			e.printStackTrace();
		}finally{
			return words;
		}
		
	

	}
	@RequestMapping("getdscode")
	@ResponseBody
	public String gedscode(){
		Map<String, String> map=new HashMap<String, String>();
		map.put("dsName","SWJSYSQ" );
		map.put("location","jdbc:oracle:thin:@121.248.200.5:1521:orcl" );
		libservice.getdscode(map);
		System.out.println("dscode"+libservice.getdscode(map));
		return null;
	}
	

}
